package com.etennis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.etennis.mapper.NoticeMapper;
import com.etennis.pojos.entity.Notice;
import com.etennis.pojos.vo.web.PublicityVO;
import com.etennis.service.INoticeService;
import com.etennis.utils.BeanCopyUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService {
    @Autowired
    NoticeMapper noticeMapper;
    @Override
    public List<PublicityVO> publicity() {
        // todo 可见度
        List<Notice> list = noticeMapper.selectList(new LambdaQueryWrapper<>());
        return list.stream().map(each -> {
            PublicityVO publicityVO = BeanCopyUtils.copyBean(each, PublicityVO.class);
            return publicityVO;
        }).collect(Collectors.toList());
    }
}
